﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace DissipativeInputProcessing
{
    public class FramePoolFactory
    {
        private static object syncRoot = new object();

        private static FramePoolFactory instance;

        public static FramePoolFactory Instance
        {
            get
            {
                if(instance==null)
                {
                    lock(syncRoot)
                    {
                        if(instance==null)
                            instance = new FramePoolFactory();
                    }
                }
                return instance;
            }
        }

        public IFramePool CreateFramePool(DirectoryInfo directory)
        {
            var pool = new MultipleFilesFramePool();
            pool.ReadFramesFromCatalog(directory);
            return pool;
        }

        public IFramePool CreateFramePool(FileInfo file)
        {
            var pool = new SingleFileFramePool();
            pool.ReadFramesFromFile(file);
            return pool;
        }

        public IFramePool CreateStub()
        {
            return new FramePoolStub();
        }
    }
}
